<?php
include('./library/conn.php');
$username=$_REQUEST['username'];
$password=$_REQUEST['password'];


$select="select * from usar where username='$username'";
$result=$mysqli->query($select);

if($result->num_rows>0){
    echo '<script>alert("用户名已存在")</script>';
    echo '<script>location="../src/html/sign.html"</script>';
    $mysqli->close();
    die();
}
$insert="insert into usar (username,password) values ('$username','$password')";


$res=$mysqli->query($insert);
$mysqli->close();
if($res){
    echo '<script>alert("注册成功")</script>';
    echo '<script>location="../src/html/login.html"</script>';
}


?>